﻿using System;
using System.Collections;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Connection;
using Me.Prettyprint.Cassandra.Serializers;
using Me.Prettyprint.Cassandra.Service;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api;
using Me.Prettyprint.Hector.Api.Beans;
using Me.Prettyprint.Hector.Api.Query;
using Org.Apache.Cassandra.Thrift;

namespace Me.Prettyprint.Cassandra.Model
{
    /// <summary>
    /// Default implementation of CounterRow interface. CounterRow has a key,
    /// list of CounterColumns and name serializer.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    /// <typeparam name="N"></typeparam>
    public class CounterRowImpl<K, N> : CounterRow<K, N>
    {
        public CounterRowImpl(K k, List<CounterColumn> columns, Serializer<N> nameSerializer)
        {
            if (k == null || columns == null || nameSerializer == null)
            {
                throw new NullReferenceException("Key, columns and Name serializer cannot be null");
            }
            Key = k;
            ColumnSlice = new CounterSliceImpl<N>(columns, nameSerializer);
        }
        public K Key
        {
            get;
            protected set;
        }
        public CounterSlice<N> ColumnSlice
        {
            get; protected set;
        }
        public override string ToString()
        {
            return "Row(" + Key + "," + ColumnSlice + ")";
        }
    }
}
